package com.wbao.dianniu.update;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yejianjun on 2018/9/5.
 */

public class ImChangerManager {

    private static ImChangerManager instance;
    private List<ImChangerListener> mList;

    public interface ImChangerListener {
        void imUserInfoChange(String identify, String niceName, String toUrl);
    }

    public static ImChangerManager getInstance() {
        if (null == instance) {
            instance = new ImChangerManager();
        }
        return instance;
    }

    public ImChangerManager() {
        mList = new ArrayList<ImChangerListener>();
    }

    public void imUserInfoChange(String identify, String niceName, String toUrl) {
        for (int i = 0; i < mList.size(); i++) {
            mList.get(i).imUserInfoChange(identify, niceName, toUrl);
        }
    }

    public void addListener(ImChangerListener list) {
        if (null == mList) {
            mList = new ArrayList<ImChangerListener>();
        }
        mList.add(list);
    }

    public void removeListener(ImChangerListener list) {
        if (null != mList) {
            mList.remove(list);
        }
    }

}
